package com.shen.langchain4j.controller;

import dev.langchain4j.model.chat.ChatModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 调用大模型控制层接口类
 */
@Slf4j
@RestController
@RequestMapping("/model")
public class ModelParametersController {
    @Autowired
    @Qualifier("qwen")
    private ChatModel qwen;

    @GetMapping(value = "/ask")
    public String askQwen(@RequestParam(value = "prompt", defaultValue = "你是谁") String prompt) {
        String result = qwen.chat(prompt);
        log.info("大模型输出结果为:{}", result);
        return result;
    }
}
